//
//  ZuoCuoXueShengCell.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/5/31.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "ZuoCuoXueShengCell.h"

@implementation ZuoCuoXueShengCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
//    CGFloat W = self.frame.size.width/5;
    StudentView *cub = [StudentView new];
    CGFloat W = 1.0/5;
    for (int i = 0; i<5; i++) {
        CGFloat X = W*(i%5)+10;
        CGFloat Y = i/5*50;
        CGRect rect = CGRectMake(X, Y, W-20, 50);
        StudentView *image = [[StudentView alloc]initWithFrame:rect];
        image.tag = 30+i;
        image.hidden = YES;
        [image uploadView];
        [self addSubview:image];
        if (i == 0) {
            [image mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(@0);
                make.centerY.equalTo(self.mas_centerY);
                make.width.equalTo(self).multipliedBy(W);
                make.height.mas_equalTo(40);
            }];
            cub = image;
        }else{
            [image mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cub.mas_right);
                make.centerY.equalTo(self.mas_centerY);
                make.width.equalTo(self).multipliedBy(W);
                make.height.mas_equalTo(40);
            }];
            cub = image;
        }
    }
}
- (void)layoutView{
//    CGFloat W = self.frame.size.width/5;
    for (int i = 0; i<_dataArray.count; i++) {
        StudentInformationObject *model = _dataArray[i];
//        CGFloat X = W*(i%5)+10;
//        CGFloat Y = i/5*50;
//        CGRect rect = CGRectMake(X, Y, W-20, 50);
        StudentView *image = (StudentView *)[self viewWithTag:30+i];
//        image.frame = rect;
        image.hidden = NO;
        [image.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.headImg] placeholderImage:[UIImage imageNamed:@"defalt_header"]];
        image.nameLabel.text = model.name;
        if ([model.isRight isEqualToString:@"1"]) {
            //错
            image.duiHaoImageView.selected = NO;
        }else{
            //对
            image.duiHaoImageView.selected = YES;
        }
        [image uploadView];
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
